﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using jaysJourney_v01.Common;
using Microsoft.Xna.Framework;
using jaysJourney_v01.Utils;
using Microsoft.Xna.Framework.Graphics;

namespace jaysJourney_v01.States
{
    class TutorialState : State
    {
        /**
         * MEMBER VARIABLES
         * */

        // Common
        private SpriteBatch mainSpriteBatch;
        private InputGroup menuButtonGroup;

        private Texture2D interfaceBG;

        // Buttons

        Button back;

        /**
         * METHODS
         * */

        public TutorialState(String name, StateManager stateManager) : base(name, stateManager) { }

        public override void initialize()
        {
            mainSpriteBatch = this.parentSpriteBatch;

            this.interfaceBG = this.getGame().Content.Load<Texture2D>(@"Textures\Interface\main_menu_v5");

            // Buttons
            this.back = new Button(this, "BACK", @"Textures\Interface\back_btn", @"Textures\Interface\back_btn_ac", 20, this.getGame().GraphicsDevice.Viewport.Height - 74, Color.White, false, false);

            this.menuButtonGroup = new InputGroup(this, this.mainSpriteBatch);
            this.menuButtonGroup.addButton(back);
        }

        public override void update(GameTime gameTime)
        {


            // update buttons
            Button click = this.menuButtonGroup.update(gameTime);

            if (click != null && click.getName() == "BACK") this.getStateManager().setActiveState("menuState");
        }

        public override void draw(GameTime gameTime)
        {
            // draw bg
            this.mainSpriteBatch.Draw(this.getGame().menuBg, new Rectangle(0, 0, this.getGame().GraphicsDevice.Viewport.Width, this.getGame().GraphicsDevice.Viewport.Height), new Rectangle(0, 0, this.getGame().menuBg.Width, this.getGame().menuBg.Height), Color.White);

            // draw interface bg
            this.mainSpriteBatch.Draw(this.interfaceBG, new Rectangle((this.getGame().GraphicsDevice.Viewport.Width / 2) - this.interfaceBG.Width / 2, 0, this.interfaceBG.Width, this.interfaceBG.Height), new Rectangle(0, 0, this.interfaceBG.Width, this.interfaceBG.Height), Color.White);

            // draw buttons
            this.menuButtonGroup.draw(gameTime);
        }

        public override void onEnterState()
        {
            this.back.setNewPosition(20, this.getGame().GraphicsDevice.Viewport.Height - 74);
        }
    }
}
